<?PHP

class OP_TextWidget extends OP_WidgetTemplate{
	function render(){
		$title = apply_filters('widget_title', $this->values['title']);
		$text = apply_filters( 'widget_text', $this->values['text'] );
		if ( !empty( $title ) ) { echo $this->values['before_title'] . $title . $this->values['after_title']; }
		echo '<div class="textwidget">'.$text.'</div>';
	}
	
	function do_post($post){
		$title = attribute_escape($post['title']);
		if ( current_user_can('unfiltered_html') )
			$text = stripslashes( $post['text'] );
		else
			$text = stripslashes(wp_filter_post_kses( $post['text'] ));
		return compact('title','text');
	}

	function options(){
		$title = attribute_escape($this->values['title']);
		$text = format_to_edit($this->values['text']);
		echo '<p>',
			'<input class="widefat" id="'.$this->widget->class.'-title-'.$this->values['number'].'" name="'.$this->widget->class.'['.$this->values['number'].'][title]" type="text" value="'.$title.'" />',
			'<textarea class="widefat" rows="16" cols="20" id="'.$this->widget->class.'-text-'.$this->values['number'].'" name="'.$this->widget->class.'['.$this->values['number'].'][text]">'.$text.'</textarea>',
		'</p>';
	}	

	
}
		
$widget = new OP_Widget('op_text');
$widget->setMeta('OP Text',"Arbitrary text or HTML");
$widget->setDefaults(array('title'=>'','text'=>''));

$opw_text = new OP_TextWidget($widget);
add_action('widgets_init', array($opw_text, 'init'));

?>